import Vue from "vue"

export default {
   
    addCount(state, payload){
        payload.count += 1
        
    },
    addCart(state, payload) {
        state.cartList.push(payload)
    },
    changeStatus(state,id) {
        let changeObj = state.cartList.find(item => {
            return item.iid == id;
        })
        //改变对象状态
        Vue.set(changeObj,"check",!(changeObj["check"]))
        
        //判断是否都选中
        if(state.cartList.every(item=> {
            return item.check
        })) {
            state.selectAll = true;
        }else {
            state.selectAll = false;
        }
    },
    toSelectAll(state) {
        state.selectAll = !state.selectAll;
        state.cartList.forEach(item => {
            item.check = state.selectAll;
        })
    },
    justFalse(state) {
        state.selectAll = false;
        state.cartList.forEach(item => {
            item.check = state.selectAll;
        })
    }
}